package ipad.asia.service.order;

import ipad.asia.entity.Order;
import ipad.asia.service.order.fallback.OrderFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Component
@FeignClient(value = "PROVIDER-ORDER",fallback = OrderFallback.class)
public interface OrderFeign {

    /***
     * @param shopId
     * @商家
     */
    //商家的所有订单
    @RequestMapping("/order/shop/shopId")
    public List<Order> findByShopId(@RequestParam(value = "shopId") int shopId);

    //查看商家订单状态
    @RequestMapping("/order/shop/statues")
    List<Order> findByIsCancelAndShopId(@RequestParam(value = "statues") int statues,
                                        @RequestParam(value = "shopId") int shopId);

    //商家按产品id查找商品订单
    @RequestMapping("/order/shop/productId")
    List<Order> findByProductIdAndShopId(@RequestParam(value = "productId") int productId,
                                         @RequestParam(value = "shopId") int shopId);

    //商家按照日期查找订单
    @RequestMapping("/order/shop/dates")
    List<Order> findByPayDateBetweenAndShopId(@RequestParam(value = "timeDown") LocalDateTime timeDown,
                                              @RequestParam(value = "timeUp") LocalDateTime timeUp,
                                              @RequestParam(value = "shopId") int shopId);

    //商家删除订单
    @RequestMapping("/order/shop/delete")
    void deleteByIdAndShopId(@RequestParam(value = "id") int id,
                             @RequestParam(value = "shopId") int shopId);

    //商家取消的订单
    @RequestMapping("/order/shop/get/cancel")
    List<Order> findByShopCancel(@RequestParam(value = "id") int id,
                                 @RequestParam(value = "shopId") int shopId);

    /**
     * @param consumerId
     * @顾客
     */
    //顾客所有订单
    @RequestMapping("/order/consumer/consumerId")
     List<Order> findByConsumerId(@RequestParam(value = "consumerId") int consumerId);

    //顾客查找取消的订单
    @RequestMapping("/order/consumer/get/cancel")
    List<Order> findByConsumerCancel(@RequestParam(value = "consumerId") int consumerId);

    //顾客查找商品的订单
    @RequestMapping("/order/consumer/productId")
    List<Order> findByProductIdAndConsumerId(@RequestParam(value = "productId") int productId,
                                             @RequestParam(value = "consumerId") int consumerId);

    //顾客查找订单状态
    @RequestMapping("/order/consumer/statues")
    List<Order> findByStatuesAndConsumerId(@RequestParam(value = "statues") int statues,
                                           @RequestParam(value = "consumerId") int consumerId);

    //顾客按照日期查找的订单
    @RequestMapping("/order/consumer/dates")
    List<Order> findByPayDateBetweenAndConsumerId(@RequestParam(value = "timeDown") LocalDateTime timeDown,
                                                  @RequestParam(value = "timeUp") LocalDateTime timeUp,
                                                  @RequestParam(value = "consumerId") int consumerId);

    //    //顾客取消订单
//    @RequestMapping("/order/cancelByConsumerId")
//    void cancelByConsumerId(@RequestParam(value = "id") int id,
//                            @RequestParam(value = "consumerId") int consumerId){
//         orderDao.cancelByConsumerId(id, consumerId);
//    }
    //顾客删除订单
    @RequestMapping("/order/consume/delete")
    void deleteByIdAndConsumerId(@RequestParam(value = "id") int id,
                                 @RequestParam(value = "consumerId") int consumerId);


    /**
     * @param
     * @管理员
     */
    //查看全部订单
    @RequestMapping("/order/get/all")
    List<Order> FindAll();

    //搜索产品的订单
    @RequestMapping("/order/id")
    Order findId(@RequestParam(value = "id") int id);

    //查看订单状态
    @RequestMapping("/order/statues")
    List<Order> findByStatues(@RequestParam(value = "statues") int statues);

    /**
     * 新增订单
     *
     * @param consumerId
     * @param price
     * @param productId
     * @param number
     * @param describes
     * @param shopId
     * @param createDate
     */
    @RequestMapping(  value = ("/order/add"))
    void orderAdd(@RequestParam(required = false,value = "id") int id,
                  @RequestParam(required = false,value = "consumerId") int consumerId,
                  @RequestParam(value = "price",required = false) Float price,
                  @RequestParam(value = "productId",required = false) int productId,
                  @RequestParam(value = "number",required = false)int number,
                  @RequestParam(value = "describes",required = false)String describes,
                  @RequestParam(value = "shopId",required = false)int shopId,
                  @RequestParam(value = "address",required = false)String address,
                  @RequestParam(value = "statues",required = false)int statues,
                  @RequestParam(value = "createDate",required = false) Date createDate,
                  @RequestParam(value = "payDate",required = false)Date payDate);
    /**
     * 更新订单状态
     * @param id
     * @param statues
     */
    @RequestMapping("/order/setStatue")
     void updateStatue(@RequestParam(value = "id") int id,
                             @RequestParam(value = "statues") int statues);

    @RequestMapping("/order/setPayStatue")
     void updatePayStatue(@RequestParam(value = "id") int id,
                                @RequestParam(value = "statues") int statues,
                                @RequestParam(value = "payDate")Date payDate);

    @RequestMapping( value = ("/order/del"))
     void orderDel(@RequestParam(value = "id",required = false) int id);




    @RequestMapping("/order/findByShopIdAndStatues")
     List<Order> findByShopIdAndStatues(@RequestParam(value = "shopId",required = false) int shopId,
                                              @RequestParam(value = "statues",required = false) int statues);
    @RequestMapping("findByShopIdAndIdAndStatues")
     List<Order> findByShopIdAndIdAndStatues(@RequestParam(value = "shopId",required = false) int shopId,
                                         @RequestParam(value = "id",required = false) int id,
                                         @RequestParam(value = "statues",required = false)int statues);

}